class RecommendSubject < ActiveRecord::Base
  has_many :item_recommends
  
  validates_presence_of :title
  validates_uniqueness_of :title
  
  { :hot_items => 1, :top_week_items => 2, :hot_tags => 4, :ratings => 5 }.each do |name, flag|
    named_scope name, :conditions => { :flag => flag }
  end
  
  class << self
  
    def recommend_item
    	find_by_flag(3)
    end
  
    def scroll_item
    	find_by_flag(6)
    end
  
    def hot_search
    	find_by_flag(7)
    end
    
  end
  
  def to_s
    title
  end
  
#  def to_param
#    "#{id}-#{title}"
#  end

end
